# Contributor: TBK <alpine@jjtc.eu>
# Maintainer: TBK <alpine@jjtc.eu>
pkgname=kompose
pkgver=1.21.0
pkgrel=1
pkgdesc="Tool to move from docker-compose to Kubernetes"
url="https://kompose.io/"
arch="all !mips !mips64"
license="Apache-2.0"
options="!check" # Require access to /tmp + bash, jq, ncurses
makedepends="go"
subpackages="$pkgname-bash-completion:bashcomp:noarch $pkgname-zsh-completion:zshcomp:noarch"
source="$pkgname-$pkgver.tar.gz::https://github.com/kubernetes/kompose/archive/v$pkgver.tar.gz"
builddir="$srcdir/src/github.com/kubernetes/$pkgname"

prepare() {
	mkdir -p "$srcdir/src/github.com/kubernetes/"
	ln -sf "$srcdir/$pkgname-$pkgver" "$srcdir/src/github.com/kubernetes/$pkgname"
	default_prepare
}

build() {
	GOPATH="$srcdir" make
}

package() {
	install -Dm755 $pkgname "$pkgdir/usr/bin"

	mkdir -p "$pkgdir"/usr/share/bash-completion/completions \
		"$pkgdir"/usr/share/zsh/site-functions
	# Generate completion scripts
	./kompose completion bash > "$pkgdir"/usr/share/bash-completion/completions/$pkgname
	./kompose completion zsh > "$pkgdir"/usr/share/zsh/site-functions/_$pkgname
}

bashcomp() {
	pkgdesc="Bash completion for Kompose"
	depends=""
	install_if="bash-completion $pkgname-cli=$pkgver-r$pkgrel"

	mkdir -p "$subpkgdir"/usr/share/
	mv "$pkgdir"/usr/share/bash-completion "$subpkgdir"/usr/share
}

zshcomp() {
	pkgdesc="Zsh completion for Kompose"
	depends=""
	install_if="zsh $pkgname-cli=$pkgver-r$pkgrel"

	mkdir -p "$subpkgdir"/usr/share/
	mv "$pkgdir"/usr/share/zsh "$subpkgdir"/usr/share
}

sha512sums="96a6a6335d1846c945410b9a7c2e580f736ac2f9730a68f59cdce8f699a7e83910ba21116de8a9640d550c03c7156d684457421597d0d9bcd63067e6cbb03e81  kompose-1.21.0.tar.gz"
